//
//  NSDate_DoubanAddition.m
//  CocoaBean
//
//  Created by sleeper on 5/23/10.
//  Copyright 2010 __MyCompany__ All rights reserved.
//

#import "NSDate_DoubanAddition.h"

@implementation NSDate (DoubanAddition)

+ (NSDate*)dbDateForString:(NSString*)dateString
{
	static NSDateFormatter *dateFormatter = nil;
	if (dateFormatter == nil) {
		dateFormatter = [[NSDateFormatter alloc] init];
		[dateFormatter setDateFormat:@"yyyy-MM-dd'T'HH:mm:ssZZZ"];
	}
	// We need to convert things like -08:00 to -0800
	dateString = [dateString stringByReplacingOccurrencesOfString:@":" withString:@"" options:0 range:NSMakeRange([dateString length]-3, 1)];
	return [dateFormatter dateFromString:dateString];
}

@end
